<script>
	let count = 0;
	$: doubled = count * 2;
	$: quadrupled = doubled * 2;
	$: if (count >= 3) {
		alert(`count is dangerously high!`);
		count = 2;
		console.log('count 被重置为2');
	}
	function handleClick() {
		count += 1;
	}
</script>

<button on:click={handleClick} class={count === 1 ? 'text-red-500 border border-green-500' : ''}>
	Clicked {count}
	{count === 1 ? '中文' : 'times'}
</button>

<p>{count} * 2 = {doubled}</p>
<p>{doubled} * 2 = {quadrupled}</p>
